<<<<<<< Updated upstream
<?php
namespace app\index\controller;

use think\Controller;
use think\Config;

class Test
{
	/**
	*用于测试
	*/
	public function test()
	{

	}
	/**
	*开发阶段用于显示数据库字典
	*/
	public function dictionary()
	{
       	 $data_config = config('database');
        	$mysql_conn = @mysql_connect($data_config['hostname'], $data_config['username'], $data_config['password']) or die("Mysql connect is error.");
        	$database = $data_config['database'];
        	mysql_select_db($database, $mysql_conn);
        	mysql_query('SET NAMES utf8', $mysql_conn);
        	$table_result = mysql_query('show tables from '.$database, $mysql_conn);
         
        	$no_show_table = array();    //不需要显示的表
        	$no_show_field = array();   //不需要显示的字段
        	//取得所有的表名
        	while($row = mysql_fetch_array($table_result)){
            		if(!in_array($row[0],$no_show_table)){
                		$tables[]['TABLE_NAME'] = $row[0];
            		}
        	}
        	//循环取得所有表的备注及表中列消息
        	foreach ($tables as $k=>$v) {
            		$sql  = 'SELECT * FROM ';
            		$sql .= 'INFORMATION_SCHEMA.TABLES ';
            		$sql .= 'WHERE ';
            		$sql .= "table_name = '{$v['TABLE_NAME']}'  AND table_schema = '{$database}'";
            		$table_result = mysql_query($sql, $mysql_conn);
            		while ($t = mysql_fetch_array($table_result) ) {
                		$tables[$k]['TABLE_COMMENT'] = $t['TABLE_COMMENT'];
            		}
	            $sql  = 'SELECT * FROM ';
	            $sql .= 'INFORMATION_SCHEMA.COLUMNS ';
	            $sql .= 'WHERE ';
	            $sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '{$database}'";
	         
	            $fields = array();
	            //$sql = "SHOW COLUMNS FROM {$v['TABLE_NAME']}";
	            $field_result = mysql_query($sql, $mysql_conn);
	            //echo $sql."\n";
	            while ($t = mysql_fetch_array($field_result) ) {
	                $ls = array();
	                $ls['EXTRA'] = $t['EXTRA'];
	                $ls['TABLE_NAME'] = $t['TABLE_NAME'];
	                $ls['COLUMN_NAME'] = $t['COLUMN_NAME'];
	                $ls['COLUMN_DEFAULT'] = $t['COLUMN_DEFAULT'];
	                $ls['IS_NULLABLE'] = $t['IS_NULLABLE'];
	                $ls['DATA_TYPE'] = $t['DATA_TYPE'];
	                $ls['COLUMN_TYPE'] = $t['COLUMN_TYPE'];
	                $ls['COLUMN_COMMENT'] = $t['COLUMN_COMMENT'];
	                $fields[] = $ls;
	                //$fields[] = $t;
	            }
	            $tables[$k]['TABLE_NAME'] = substr( $tables[$k]['TABLE_NAME'], strpos( $tables[$k]['TABLE_NAME'], '_'));
            		$tables[$k]['COLUMN'] = $fields;
        	}
		mysql_close($mysql_conn);
		return view('test/dictionary',[
			'tables'=>$tables,
			]);
		return $tables;
	}
=======
<?php
namespace app\index\controller;

use think\Controller;
use think\Config;
use think\Loader;
use app\index\model\User;
use auth\Auth;
//use app\index\libs\Mcrypt;
use crypt\Mcrypt;

class Test
{
	/**
	*用于测试
	*/
	public function test()
	{
                var_dump(Auth::check());
                var_dump(Auth::user());
	}
	/**
	*开发阶段用于显示数据库字典
	*/
	public function dictionary()
	{
       	 //其他配置
       	 $data_config = config('database');
        	$mysql_conn = @mysql_connect($data_config['hostname'], $data_config['username'], $data_config['password']) or die("Mysql connect is error.");
        	$database = $data_config['database'];
        	mysql_select_db($database, $mysql_conn);
        	mysql_query('SET NAMES utf8', $mysql_conn);
        	$table_result = mysql_query('show tables from '.$database, $mysql_conn);
         
        	$no_show_table = array();    //不需要显示的表
        	$no_show_field = array();   //不需要显示的字段
        	//取得所有的表名
        	while($row = mysql_fetch_array($table_result)){
            		if(!in_array($row[0],$no_show_table)){
                		$tables[]['TABLE_NAME'] = $row[0];
            		}
        	}
        	//循环取得所有表的备注及表中列消息
        	foreach ($tables as $k=>$v) {
            		$sql  = 'SELECT * FROM ';
            		$sql .= 'INFORMATION_SCHEMA.TABLES ';
            		$sql .= 'WHERE ';
            		$sql .= "table_name = '{$v['TABLE_NAME']}'  AND table_schema = '{$database}'";
            		$table_result = mysql_query($sql, $mysql_conn);
            		while ($t = mysql_fetch_array($table_result) ) {
                		$tables[$k]['TABLE_COMMENT'] = $t['TABLE_COMMENT'];
            		}
	            $sql  = 'SELECT * FROM ';
	            $sql .= 'INFORMATION_SCHEMA.COLUMNS ';
	            $sql .= 'WHERE ';
	            $sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '{$database}'";
	         
	            $fields = array();
	            //$sql = "SHOW COLUMNS FROM {$v['TABLE_NAME']}";
	            $field_result = mysql_query($sql, $mysql_conn);
	            //echo $sql."\n";
	            while ($t = mysql_fetch_array($field_result) ) {
	                $ls = array();
	                $ls['EXTRA'] = $t['EXTRA'];
	                $ls['TABLE_NAME'] = $t['TABLE_NAME'];
	                $ls['COLUMN_NAME'] = $t['COLUMN_NAME'];
	                $ls['COLUMN_DEFAULT'] = $t['COLUMN_DEFAULT'];
	                $ls['IS_NULLABLE'] = $t['IS_NULLABLE'];
	                $ls['DATA_TYPE'] = $t['DATA_TYPE'];
	                $ls['COLUMN_TYPE'] = $t['COLUMN_TYPE'];
	                $ls['COLUMN_COMMENT'] = $t['COLUMN_COMMENT'];
	                $fields[] = $ls;
	                //$fields[] = $t;
	            }
	            $tables[$k]['TABLE_NAME'] = substr( $tables[$k]['TABLE_NAME'], strpos( $tables[$k]['TABLE_NAME'], '_'));
            		$tables[$k]['COLUMN'] = $fields;
        	}
		mysql_close($mysql_conn);
		return view('test/dictionary',[
			'tables'=>$tables,
			]);
		return $tables;
	}
>>>>>>> Stashed changes
}